import React, { Component } from 'react';
import ChildC from './components/ChildC';
class App extends Component {
  state = { show:true,value:5 } 
  render() { 
    // 定义show
    var show = this.state.show;
    return (<div>
      <p><button onClick={()=>this.setState({show:!show})}>切换</button></p>
      {show&&<ChildC value={this.state.value}></ChildC>}
      <p>父组件value:{this.state.value}
        <button onClick={()=>this.setState({value:5})}>更新</button>
        <button onClick={()=>this.setState({value:this.state.value+1})}>更新1</button>
      </p>
    </div>);
  }
}
 
export default App;